package com.dwxt.community.dao;

import com.dwxt.community.entity.*;
import com.dwxt.community.entity.vo.UserVO;
import org.apache.ibatis.annotations.*;

import java.util.*;

public interface UserMapper {
    long countByExample(UserExample example);

    int deleteByExample(UserExample example);

    int deleteByPrimaryKey(String id);

    int insert(User record);

    int insertSelective(User record);

    List<User> selectByExample(UserExample example);

    User selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    User selectHouseOwnerByUserId(String id);
    //总用户数
    @Select("SELECT COUNT(*) FROM `user`;")
    int selectTotalUsers();
    //知晓率
    @Select("SELECT CONCAT(ROUND(COUNT(*)/273200*100,2),'%') FROM `user`;")
    String selectAwareness();
    //垃圾分类活跃人数
    @Select("SELECT COUNT(DISTINCT deliverer_id)  FROM trash_integral_recoad;")
    int selectActiveUser();
    //总参与率
    @Select("SELECT CONCAT( ROUND( trash.count / 273200 * 100, 2 ), '%' ) FROM ( SELECT COUNT( DISTINCT deliverer_id ) count FROM trash_integral_recoad ) AS trash;")
    String selectTotalParticipation();

    List<User> getTotalTrashIntegralUserPageInfo(UserVO userVo);

    List<User> getTrashCountUserPageInfo(UserVO userVo);

    Integer countDemonstrationUser(Integer isOfficer);

    @Select("SELECT COUNT(*) FROM `user` WHERE community_id=#{id,jdbcType=INTEGER};")
    int selectTotalUsersByCommunityId(@Param("id") Integer id);

    Integer countUserByCreateTime(String date);

}